package com.webgis.backendservice.controller;

import com.webgis.backendservice.pojo.Poi;
import com.webgis.backendservice.pojo.Rate;
import com.webgis.backendservice.pojo.Route;
import com.webgis.backendservice.service.POIService;
import com.webgis.backendservice.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@CrossOrigin //跨域
public class POIController {
    @Autowired
    private POIService poiService;

    @GetMapping("poi")
    public List<Poi> getPOI(){
        return poiService.getPOI();
    }
    @GetMapping("rate/{treeId}")
    public List<Rate> getRateByUser(@PathVariable int treeId){
        return poiService.getRateByUser(treeId);
    }

    @PostMapping("rate")
    public void addRate(@RequestBody Rate rate){
        poiService.addRate(rate);
    }

    @PostMapping ("route")
    public void addRoute(@RequestBody Route route) {
        poiService.addRoute(route);
    }

    @GetMapping("route")
    public List<Route> getRoute() {
        return poiService.getRoute();
    }

}
